//
//  CooperationAlertView.m
//  share_business
//
//  Created by baidufz on 2017/9/17.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "CooperationAlertView.h"

#define ScreenWidth      [UIScreen mainScreen].bounds.size.width
#define ScreenHeight     [UIScreen mainScreen].bounds.size.height

@interface CooperationAlertView ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UITextField *nameInput;
@property (weak, nonatomic) IBOutlet UITextField *phoneInput;
@property (weak, nonatomic) IBOutlet UITextField *referralsInput;


@end

@implementation CooperationAlertView

//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        UIView *contentView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
//        [self addSubview:contentView];
//    }
//    return self;
//}

- (instancetype)initWithTitle:(NSString *)title {
    if (self == [super init]) {
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [UIColor colorWithWhite:0.6 alpha:0.5];
        
        
        UIView *contentView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
        contentView.backgroundColor = [UIColor whiteColor];
        contentView.layer.cornerRadius = 5.0;
        contentView.frame = CGRectMake(0, 0, 330, 284);
        contentView.layer.position = self.center;
        
        [self addSubview:contentView];

    }
    return self;
}

- (IBAction)submit:(id)sender {
}

- (IBAction)close:(id)sender {
    [self removeFromSuperview];
}

- (void)showAlert {
    UIWindow *rootWindow = [UIApplication sharedApplication].keyWindow;
    [rootWindow addSubview:self];
    [self creatShowAnimation];
}
- (void)creatShowAnimation
{
    self.layer.position = self.center;
    self.transform = CGAffineTransformMakeScale(0.90, 0.90);
    [UIView animateWithDuration:0.25 delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:1 options:UIViewAnimationOptionCurveLinear animations:^{
        self.transform = CGAffineTransformMakeScale(1.0, 1.0);
    } completion:^(BOOL finished) {
    }];
}


@end
